package com.kalua.list.dbaccess.retailer;

import org.springframework.cassandra.core.RowMapper;

import com.datastax.driver.core.Row;
import com.datastax.driver.core.exceptions.DriverException;
import com.kalua.list.domainmodel.TextIdentifier;
import com.kalua.list.domainmodel.retailer.Retailer;
import com.kalua.list.domainmodel.retailer.RetailerImpl;

public class RetailerRowMapper implements RowMapper<Retailer>{

	public static final String RETAILER_COL_FAMILY = "retailer";
	public static final String RETAILER_ID_COL_NAME = "retailer_id";
	public static final String TRADING_NAME_COL_NAME = "trading_name";
	public static final String LOGO_URI_COL_NAME = "logo_uri";
	
	@Override
	public Retailer mapRow(Row row, int rowNum) throws DriverException {
		RetailerImpl result;
		
		result = new RetailerImpl(new TextIdentifier(row.getString(RETAILER_ID_COL_NAME)), 
												row.getString(TRADING_NAME_COL_NAME), 
												row.getString(LOGO_URI_COL_NAME));		
		return result;
	}
}
